﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MJB.UI.ContentEditor.Windows;
using MJB.UI.ContentEditor.Document;
using MJB.UI.ContentEditor.Document.Version1;

namespace MJB.UI.ContentEditor.UserControls
{
    /// <summary>
    /// Defines the logic behind the tab control header class.
    /// </summary>
    public partial class TabItemHeaderControl : UserControl
    {
        /// <summary>
        /// Initializes the component.
        /// </summary>
        public TabItemHeaderControl()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Called when the close image is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void OnCloseImageClicked(object sender, EventArgs args)
        {
            Image image = (Image)sender;
            IDocumentReader documentReader = (IDocumentReader)image.DataContext;

            // We have to get the MainWindow object, which
            // is somewhere down our visual tree:
            MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
            mainWindow.RemoveDocumentReader(documentReader);

        }

    }

}
